'use strict';
new Component({
  options: {
    addGlobalClass: true,
  },
  externalClasses: ['lee-class'],
  properties: {
    icon: {
      type: String,
      value: '',
    },

    round: {
      type: Boolean,
      value: false,
    },

    size: {
      type: String,
      value: '',
    },

    color: {
      type: String,
      value: '',
    },

    ghost: {
      type: Boolean,
      value: false,
    },

    gradual: {
      type: Boolean,
      value: false,
    },

    long: {
      type: Boolean,
      value: false,
    },

    disabled: {
      type: Boolean,
      value: false,
    },

    loading: {
      type: Boolean,
      value: false,
    },

    prefix: {
      type: String,
      value: '',
    },

    suffix: {
      type: String,
      value: '',
    },

    formType: {
      type: String,
      value: '',
    },

    openType: {
      type: String,
      value: '',
    },

    lang: {
      type: String,
      value: 'en',
    },

    sessionForm: {
      type: String,
      value: '',
    },

    sendMessageTitle: {
      type: String,
      value: '',
    },

    sendMessagePath: {
      type: String,
      value: '',
    },

    sendMessageImg: {
      type: String,
      value: '',
    },

    appParameter: {
      type: String,
      value: '',
    },

    showMessageCard: {
      type: String,
      value: '',
    },

    to: {
      type: String,
      value: '',
    },

    toType: {
      type: String,
      value: 'navigateTo',
    },
  },

  methods: {
    onClick() {
      const { to, toType } = this.data;
      if (to && [
        'switchTab', 'reLaunch', 'redirectTo', 'navigateTo',
      ].includes(toType)) {
        wx[toType]({ url: to });
      }

      this.triggerEvent('on-click');
    },

    onGetUserInfo(e) {
      this.triggerEvent('getuserinfo', e);
    },

    onContact(e) {
      this.triggerEvent('contact', e);
    },

    onGetPhoneNumber(e) {
      this.triggerEvent('getphonenumber', e);
    },

    onError(e) {
      this.triggerEvent('error', e);
    },

    onOpenSetting(e) {
      this.triggerEvent('opensetting', e);
    },

    onLaunchApp(e) {
      this.triggerEvent('launchapp', e);
    },
  },
});
